const app = getApp();
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		theme: app.theme,
		user: {},
		orderid: "",
		sname: ""
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function (options) {
		this.data.orderid = options.orderid;
		this.data.sname = options.sname;
		this.data.user = app.functions.getLocalStorage("user");
	},
	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function () {

	},
	toShop() {
		wx.switchTab({
			url: '/pages/index/index'
		});
	},
	lookDetail() {
		let backurl = "/pages_user/order-detail/order-detail?orderid=" + this.data.orderid;
		wx.redirectTo({
			url: backurl
		})
	},
	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow: function () {

	},

	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function () {

	},

	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function () {

	},

	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh: function () {

	},

	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom: function () {

	},

	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function () {
		let user = app.functions.getLocalStorage("user");
		let share = {};
		let backurl = "/pages_subpack/order_detail/order_detail?orderid=" + this.data.orderid;
		app.getGlobalShare((shareData) => {
			if (user.isteam === 3) {
				share = {
					title: this.replateShare(shareData.masterOrderShareTitle),
					path: backurl,
					imageUrl: shareData.masterOrderShareIcon
				};
			} else {
				share = {
					title: this.replateShare(shareData.customOrderShareTitle),
					path: backurl,
					imageUrl: shareData.customOrderShareIcon
				};
			}
		});
		return share;
	},
	replateShare(value) {
		let user = app.functions.getLocalStorage("user");
		return value.replace(/{nickname}/, user.nickname).replace(/{sname}/, this.data.sname);
	}
})